
/**
 * 
 */
/**
 * @param {string} s
 */
 var lengthOfLongestSubstring = function(s) {
    let maxStr = ''
    let currstr = ''
    const sn = s.split('')
    const getMaxStr = (v, i, type) => {
        if (v.indexOf(sn[i + type]) === -1 && sn[i]) {
            currstr = v + (sn[i + type] || '')
            getMaxStr(v + sn[i + type], i + type, type)
        }
    }
    
    sn.forEach((v, i) => {
        getMaxStr(v, i, 1)
        getMaxStr(currstr, i, -1)
        if (currstr.length > maxStr.length) {
            maxStr = currstr
        }
    })
    return maxStr.length
};


